package com.uuuo.ugamepluginsdk;

import android.app.Application;
import android.util.Log;

import com.uuuo.ugamepluginsdk.droidfix.DroidFix;

import java.io.File;
import java.io.IOException;

/**
 * Created by JiaTao on 2017/11/10.
 * Email: 535318720@qq.com
 * Version: 1.0
 * Description:
 */

public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        try {
            File dest = new File(getFilesDir(), DroidFix.DROID_CODE_CACHE);
            if (!dest.exists()) {
                Log.i("111111", dest.getAbsolutePath() + "不存在!");
                dest.mkdirs();
            }

            if (dest.exists()) {
                File file = new File(dest, "fix.txt");
                file.createNewFile();
                if (file.exists()) {
                    Log.i("333333", file.getAbsolutePath() + "存在!");
                } else {
                    Log.i("444444", file.getAbsolutePath() + "不存在!");
                }

            } else {
                Log.i("222222", dest.getAbsolutePath() + "不存在!");
                return;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

//        File fixFile = new File(Environment.getExternalStorageDirectory(), "fix.apk");
//
//        File destDir = new File(getFilesDir(), DroidFix.DROID_CODE_CACHE);
//        if (!destDir.exists()) {
//            destDir.mkdirs();
//        }
//
//
//        File dest = new File(getFilesDir(), DroidFix.DROID_CODE_CACHE + File.separator + "fix.apk");
//        try {
//            if (!dest.exists()) {
//                FileUtil.copyFile(fixFile, dest);
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        if (dest.isFile() && dest.exists()) {
//           new  DroidFix().installPatch(this, dest);
//        }

    }
}
